package com.zxl.grocery.modular.crawler.warpper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zxl.grocery.core.base.warpper.BaseControllerWrapper;
import com.zxl.grocery.core.common.constant.factory.ConstantFactory;
import com.zxl.grocery.kernel.model.page.PageResult;

import java.util.List;
import java.util.Map;

/**
 * 爬虫来源列表的包装类
 * Created by zxl on 2017/8/1 0001.
 */
public class CrawlerMgrWarpper extends BaseControllerWrapper {

    public CrawlerMgrWarpper(Map<String, Object> single) {
        super(single);
    }

    public CrawlerMgrWarpper(List<Map<String, Object>> multi) {
        super(multi);
    }

    public CrawlerMgrWarpper(Page<Map<String, Object>> page) {
        super(page);
    }

    public CrawlerMgrWarpper(PageResult<Map<String, Object>> pageResult) {
        super(pageResult);
    }

    @Override
    protected void wrapTheMap(Map<String, Object> map) {
        if (map.containsKey("status")) {
            Integer status = (Integer) map.get("status");
        }
        if (map.containsKey("createUserId")) {
            Long createUserId = Long.valueOf(map.get("createUserId").toString());
            map.put("createUserName", ConstantFactory.me().getUserNameById(createUserId));
        }
        if (map.containsKey("updateUserId")) {
            Long updateUserId = Long.valueOf(map.get("updateUserId").toString());
            map.put("updateUserName", ConstantFactory.me().getUserNameById(updateUserId));
        }
    }
}
